from flask import current_app, Blueprint, render_template, request
from app import db

module_dd_nex = Blueprint('da_dong_nex', __name__, template_folder='templates')


@module_dd_nex.route('/')
def production_volume():
    return render_template('production_volume.html')


@module_dd_nex.route('/api/production_volume', methods=['GET'])
def api_for_production_volume():
    from app.helper.nex import query_production_volume
    db_engine = db.get_engine(current_app, bind='IPS_T_Dadong_Prod_Online')
    volume_type = request.args.get('type')
    return query_production_volume(db_engine, volume_type)
